//-----------------------------------------------------------------------------
//
// @file	Image.h
// @brief	Image include files, variables and classes
// @author	Vinod Melapudi
// @date	20Feb2010
//
//-----------------------------------------------------------------------------

#ifndef _IMAGE_H
#define _IMAGE_H

#include "Color.h"
#include "FileOps.h"
#include "GL/gl.h"

enum IMAGE_TYPE
{
	IMAGE_BMP,
	IMAGE_PNG
};

class Image
{
public:
	Image();
	~Image();

	Image( const char * fileName, IMAGE_TYPE type );

	// R/W image from/to file
	bool Read( const char * fileName, IMAGE_TYPE type );
	bool Write( const char * fileName, IMAGE_TYPE type );

	// Load viewport into image
	bool LoadViewport();

	// Load
	void LoadColor( int width, int height, const std::vector<Color<short>>& colors );

	// Accessors
	uint			GetWidth() const			{ return m_width; }
	uint			GetHeight() const			{ return m_height; }
	GLenum			GetColorMode() const		{ return m_color_mode; }
	unsigned char*	GetData() const				{ return m_data; }

private:
	uint			m_width;
	uint			m_height;
	GLenum			m_color_mode;
	unsigned char*	m_data;


private:
	bool ReadBMP( const char* fileName );
	bool WriteBMP( const char* fileName );
	bool ReadPNG( const char* fileName );
	bool WritePNG( const char* fileName );
};

#endif